global FirstRow,NbrCols,LastRow,PayCol,DepCol,BalCol
set cursor to 4
put "Last balanced" & return & the abbrev date into card field "Last Balanced"
set numberFormat to "0.00"
put 4 into XCol
put empty into card field "Checks Out"
put empty into card field "Deps Out"
put zero into card field "Total Deps"
put zero into card field "Total Checks"
get card field "Balance" of first card
delete first char of it -- Get rid of "$".
put it into card field "Book Balance Is"
put empty into card field "Book Balance SB"
put empty into card field "Error"
repeat with j = (the number of first card of bkgnd "CheckReg") to (the number of last card of bkgnd "CheckReg")
put FirstRow into i
set lockMessages to true
repeat
if i > LastRow then exit repeat
set lockScreen to true
go to card j
if field (i + XCol) is empty then
get field (i + DepCol)
if it is not empty then
put field (i + 1) into dat
if length(dat) < 12 then put space before char 8 of dat
put right(field i,5) && dat && left(first line of field (i + 2),35) && right(it,9) & return into linex
go to card "Balance"
set lockScreen to false
put (((the number of lines in card field "Deps Out") + 1) * (the textHeight of card field "Deps Out") + 8) - ((item 4 of the rect of card field "Deps Out") - (item 2 of the rect of card field "Deps Out")) into scrollx
if scrollx < 0 then put 0 into scrollx
set scroll of card field "Deps out" to scrollx
put linex after card field "Deps Out"
add it to card field "Total Deps"
set lockScreen to true
go to card j
end if
get field (i + PayCol)
if it is not empty then
put field (i + 1) into dat
if length(dat) < 12 then put space before char 8 of dat
put right(field i,5) && dat && left(first line of field (i + 2) ,35) && right(it,9) & return into linex
go to card "Balance"
set lockScreen to false
put (((the number of lines in card field "Checks Out") + 1) * (the textHeight of card field "Checks Out") + 8) - ((item 4 of the rect of card field "Checks Out") - (item 2 of the rect of card field "Checks Out")) into scrollx
if scrollx < 0 then put 0 into scrollx
set scroll of card field "Checks out" to scrollx
put linex after card field "Checks Out"
add it to card field "Total Checks"
--set lockScreen to true
--go to card j
end if
end if
go to card "Balance"
set lockScreen to false
add NbrCols to i
end repeat
set lockMessages to false
end repeat
totals
end balance
on totals
set numberFormat to "0.00"
get card field "Stmt Balance"
if it is empty then get zero
add (card field "Total Deps") - (card field "Total Checks") to it
put it into card field "Book Balance SB"
get it - (card field "Book Balance Is")
if it is zero then get "** Zero **"
else if first char of it is not "-" then put "+" before it